/**
 * @file t_dht11.c
 * @author TimeChicken (https://gitee.com/Time--Chicken)
 * @brief DHT11温湿度测试程序
 * @version 0.1
 * @date 2021-11-11
 * 
 * @copyright Copyright (c) 2021
 * 
 */
#ifdef DHT11_C_TEST
#include <stm32f4xx.h>
#include <string.h>
#include <stdio.h>
#include "usart.h"
#include "dht11.h"

int main(void)
{
    DHT11_DataTypeDef dht11_data;

    USART1_Config(115200);
    dht11_Init();

    print_ln("here is DHT11 test.");
    while(1)
    {
        dht11_data = dht11_read();
		if(dht11_data.humidity < 0 || dht11_data.temperature < 0)
		{
			print_ln("read dht11 data error.");
		}
        else
		{
			print_ln("dht11_data: Humi:%.0f%% Temp:%.1f°C", \
			dht11_data.humidity, dht11_data.temperature);
		}
        delay_ms(1200); // 最小极限1103ms，小于这个时间会读取不了第二次数据
    }
}

#endif /* DHT11_C_TEST */
